import { getArticleAll, getCommentAll } from "@/services";
import { useEffect, useState } from "react"

const workbench: React.FC = () => {
    const [articleAll, setArticleAll] = useState<[]>([])
    const [commentAll, setCommentAll] = useState<[]>([])
    const user: any = JSON.parse(sessionStorage.getItem('user'))
    console.log(user);


    useEffect(() => {
        // 最新文章
        getArticleAll().then(result => {
            if (result.statusCode === 200) {
                setArticleAll(result.data[0])
            }
        })
        //所有评论
        getCommentAll().then(result => {
            if (result.statusCode === 200) {
                setCommentAll(result.data[0])
            }
        })
    }, [])
    // console.log("ArticleAll...", articleAll);
    // console.log("CommentAll...", commentAll);
    return (
        <div>
            <header>
                <div>工作台</div>
                <div>
                    <h1>您好,{user.name}</h1>
                </div>
                <div>您的角色:{user.role == 'visitor' ? '访客' : ''}</div>
            </header>
        </div>
    )
}
export default workbench